home *** CD-ROM | disk | FTP | other *** search
/ Language/OS - Multiplatform Resource Library / LANGUAGE OS.iso / gnu / smaltalk.lha / smalltalk-1.1.1 / ReadStream.st < prev    next >
Text File  |  1991-09-12  |  2KB  |  83 lines

  1. "======================================================================
  2. |
  3. |   ReadStream Method Definitions
  4. |
  5.  ======================================================================"
  6.  
  7.  
  8. "======================================================================
  9. |
  10. | Copyright (C) 1990, 1991 Free Software Foundation, Inc.
  11. | Written by Steve Byrne.
  12. |
  13. | This file is part of GNU Smalltalk.
  14. |
  15. | GNU Smalltalk is free software; you can redistribute it and/or modify it
  16. | under the terms of the GNU General Public License as published by the Free
  17. | Software Foundation; either version 1, or (at your option) any later version.
  18. | GNU Smalltalk is distributed in the hope that it will be useful, but WITHOUT
  19. | ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
  20. | FOR A PARTICULAR PURPOSE.  See the GNU General Public License for more
  21. | details.
  22. | You should have received a copy of the GNU General Public License along with
  23. | GNU Smalltalk; see the file COPYING.  If not, write to the Free Software
  24. | Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.  
  25. |
  26.  ======================================================================"
  27.  
  28.  
  29. "
  30. |     Change Log
  31. | ============================================================================
  32. | Author       Date       Change 
  33. | sbyrne     19 Sep 89      Converted to use real method categories.
  34. |
  35. | sbyrne     25 Apr 89      created.
  36. |
  37. "
  38.  
  39. PositionableStream subclass: #ReadStream
  40.            instanceVariableNames: ''
  41.            classVariableNames: ''
  42.            poolDictionaries: ''
  43.            category: nil.
  44.  
  45. ReadStream comment: 
  46. 'I implement the set of read-only stream objects.  You may read from
  47. my objects, but you may not write to them.' !
  48.  
  49. !ReadStream class methodsFor: 'instance creation'!
  50.  
  51. on: aCollection
  52.     ^(self new initCollection: aCollection) access: 1
  53. !!
  54.  
  55.  
  56.  
  57. !ReadStream methodsFor: 'accessing-reading'!
  58.  
  59. reverseContents
  60.     "May be faster than generic stream reverseContents."
  61.     | aCollection i numElts |
  62.     numElts _ collection size.
  63.     aCollection _ collection species new: numElts.
  64.     i _ 1.
  65.     [ i < endPtr ] whileTrue:
  66.         [ aCollection at: numElts - i + 1
  67.                   put: (collection at: i) ].
  68.     ^aCollection
  69. !!
  70.  
  71.  
  72.  
  73. !ReadStream methodsFor: 'private methods'!
  74.  
  75. initCollection: aCollection
  76.     collection _ aCollection.
  77.     ptr _ 1.
  78.     endPtr _ collection size
  79.  
  80. !!
  81.